﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;

namespace Quartz.Net.DAL
{
    public class OracleHelper
    {
        private string _connStr;

        public OracleHelper(string connstr)
        {
            _connStr = connstr;
        }
        
        public int ExecuteNonQuery(string strSql,params OracleParameter[] para)
        {
            using (OracleConnection conn = new OracleConnection(_connStr))
            {
                conn.Open();
                using (OracleCommand cmd = new OracleCommand(strSql,conn))
                {
                    if (para != null)
                    {
                        cmd.Parameters.AddRange(para);
                    }
                    return cmd.ExecuteNonQuery();
                }
            }
        }

        public DataTable ExecuteDataTable(string strSql,params OracleParameter [] para)
        {
            DataTable dt = new DataTable();
            using (OracleDataAdapter dap = new OracleDataAdapter(strSql,_connStr))
            {
                if (para != null)
                {
                    dap.SelectCommand.Parameters.AddRange(para);
                }
                dap.Fill(dt);
                return dt;
            }
        }

    }
}
